package org.biubiu0002.baiblog.core.utils;

import okhttp3.*;

/**
 * @Author: biubiu0002
 * @Date: 2022/11/2 1:50
 **/
public class HttpUtils {

    private static OkHttpClient okHttpClient = new OkHttpClient();
    ;


    public static Response get(String url) {
        try {
            Request.Builder builder = new Request.Builder();
            Request request = builder.url(url).get().build();
            return okHttpClient.newCall(request).execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }

    public static Response post(String url) {
        try {
            Request.Builder builder = new Request.Builder();
            Request request = builder.url(url).post(RequestBody.create(MediaType.get("application/json"), "")).build();
            return okHttpClient.newCall(request).execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }
}
